package tts.controller.groups;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;

import tts.controller.RedirectAction;
import tts.dao.GroupsHome;
import tts.model.Groups;

public class List extends RedirectAction {

	//fields
	private static final long serialVersionUID = -86966939953569102L;
	@Autowired
	private GroupsHome groupsHome;
	private Collection<Groups> groupsList;

	//get & set
	public Collection<Groups> getGroupsList() {
		return groupsList;
	}
	public void setGroupsList(Collection<Groups> groupsList) {
		this.groupsList = groupsList;
	}

	//methods
	public void list() {
		try {
			this.groupsList=groupsHome.findAll();
			this.getServletRequest().setAttribute("groupsList", groupsList);
		} catch (RuntimeException e) {
			addActionError(e.getMessage());
		}
	}
}